﻿using Dyao.Book.Application.Abstractions;
using Dyao.Book.Contract;
using Foundation.Core;
using Microsoft.Extensions.DependencyInjection;

namespace Dyao.Book.Application
{
    public class TaskCenterParametersSerializerFactory : ITaskCenterParametersSerializerFactory, ITransientDependency
    {
        private readonly IServiceProvider _serviceProvider;
        private ITaskCenterRequestParamsSerializer _defaultSerializer;

        public TaskCenterParametersSerializerFactory(IServiceProvider serviceProvider)
        {
            this._serviceProvider = serviceProvider;
        }
        public ITaskCenterRequestParamsSerializer Create(TaskCenterDto taskCenterModel)
        {
            //可以根据 TaskCenterDto 参数返回不同序列化器

            if (_defaultSerializer == null)
            {
                _defaultSerializer = _serviceProvider.GetService<TaskCenterRequestParamsSerializerForDateFilterService>();
            }

            return _defaultSerializer;
        }

    }
}
